﻿@using Sausage.Web.Models
@using Sausage.Web.DataModel
@using Telerik.Web.Mvc.UI
@using Sausage.Web.Domain
@model DictionaryItemListRow
@{
    ViewBag.Title = "养护机械填报";
    Layout = "~/Views/Shared/MainLayout.cshtml";

    //用于保存类型信息
    List<string> machineModels = new List<string>();

    //用于保存类型信息
    List<string> machineTypeModels = new List<string>();

    //用于保存油料信息
    List<string> oilTypeModels = new List<string>();

    //用于保存单位信息
    List<string> unitModels = new List<string>();

    //查询信息
    using (SausageEntities entities = new SausageEntities())
    {
        //查询所有台班单位信息
        foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 6).OrderBy(item => item.ItemName).ToArray())
        {
            //判断是否为空字符
            if (string.IsNullOrEmpty(item.ItemPinYin))
            {
                //转换为字符串
                unitModels.Add(string.Format(@"{{ ID: '{0}', Name: '{0}' }}", item.ItemID, item.ItemName));
            }
            else
            {
                //转换为字符串
                unitModels.Add(string.Format(@"{{ ID: '{0}', Name: '{1} {2}' }}", item.ItemID, item.ItemPinYin, item.ItemName));
            }
        }

        //查询所有机械类型信息
        foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 7).OrderBy(item => item.ItemName).ToArray())
        {
            //判断是否为空字符
            if (string.IsNullOrEmpty(item.ItemPinYin))
            {
                //转换为字符串
                machineModels.Add(string.Format(@"{{ ID: '{0}', Name: '{0}' }}", item.ItemID, item.ItemName));
            }
            else
            {
                //转换为字符串
                machineModels.Add(string.Format(@"{{ ID: '{0}', Name: '{1} {2}' }}", item.ItemID, item.ItemPinYin, item.ItemName));
            }
        }

        //查询所有机械类型信息
        foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 9).OrderBy(item => item.ItemName).ToArray())
        {
            //判断是否为空字符
            if (string.IsNullOrEmpty(item.ItemPinYin))
            {
                //转换为字符串
                machineTypeModels.Add(string.Format(@"{{ ID: '{0}', Name: '{0}' }}", item.ItemID, item.ItemName));
            }
            else
            {
                //转换为字符串
                machineTypeModels.Add(string.Format(@"{{ ID: '{0}', Name: '{1} {2}' }}", item.ItemID, item.ItemPinYin, item.ItemName));
            }
        }

        //查询所有油料信息
        foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 13).OrderBy(item => item.ItemName).ToArray())
        {
            //判断是否为空字符
            if (string.IsNullOrEmpty(item.ItemPinYin))
            {
                //转换为字符串
                oilTypeModels.Add(string.Format(@"{{ ID: '{0}', Name: '{0}' }}", item.ItemID, item.ItemName));
            }
            else
            {
                //转换为字符串
                oilTypeModels.Add(string.Format(@"{{ ID: '{0}', Name: '{1} {2}' }}", item.ItemID, item.ItemPinYin, item.ItemName));
            }
        }
    }      
}
@section HeadCssLink
{
    <link href="@Url.Content("~/Content/Styles/ext-patch.css")" rel="stylesheet" type="text/css" />
}
@section HeadScriptLink
{
    <script src="@Url.Content("~/Scripts/ExtJS/locale/ext-lang-zh_CN.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/model.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Sausage/MaintainMachine/Submit.js")" type="text/javascript"></script>
    <script type="text/javascript">
        //用于保存机械信息
        var master_machine =
        [
            @Html.Raw(System.String.Join(",", machineModels))
        ];

        //用于保存类型信息
        var master_machine_type =
        [
            @Html.Raw(System.String.Join(",", machineTypeModels))
        ];

        //用于保存油料信息
        var master_oil =
        [
            @Html.Raw(System.String.Join(",", oilTypeModels))
        ];

        //用于保存单位信息
        var master_machine_unit =
        [
            @Html.Raw(System.String.Join(",", unitModels))
        ];

        //用于保存机械存储
        var store_master_machine = null;

        //用于保存机械类型存储
        var store_master_machine_type = null;

        //用于保存养护编号存储
        var store_master_quantity = null;

         //用于保油料类型存储
        var store_master_oil = null;

        //用于保存单位存储
        var store_master_unit = null;
    </script>
}
<h2>
    @ViewBag.Title
</h2>
<br />
<div id="data-grid" class="div-grid-box">
</div>
